<?php
use think\facade\Route;
use app\admin\middleware\CheckUser;
use app\admin\middleware\CheckPermi;
use app\admin\middleware\PrintLog;
Route::group('user', function () {
   Route::post('login', 'User/login');
   Route::post('test', 'User/test');
   Route::get('captcha', 'User/captcha');
   Route::post('logout', 'User/logout');
});

Route::group('init', function () {
   Route::get('perms', 'redisInit/initPerms');
});

Route::group(function () {
   Route::get('getRouters', 'User/getRouters');
   Route::group('user', function () {
      Route::get('userInfo', 'User/userInfo');
   });
   Route::group('index', function () {
      Route::post('getWebdata', 'Index/webdata');
      Route::get('getCount', 'Index/getCount');
   });
   Route::group('menu', function () {
      Route::post('allList', 'Menu/list')->option(['permission' => 'admin:menu:list']);
      Route::post('', 'Menu/add')->option(['permission' => 'admin:menu:add', 'logType' => '3']);
      Route::get('menuRoleTree/:id', 'Menu/menuRoleTree');
      Route::get(':id', 'Menu/get')->option(['permission' => 'admin:menu:get']);
      Route::put('', 'Menu/update')->option(['permission' => 'admin:menu:edit', 'logType' => '3']);
      Route::delete(':ids', 'Menu/del')->pattern(['ids' => '\d+(,\d+)*'])->option(['permission' => 'admin:menu:del', 'logType' => '3']);

   });
   Route::group('role', function () {
      Route::post('list', 'Role/list')->option(['permission' => 'admin:role:list']);
      Route::get(':id', 'Role/get')->option(['permission' => 'admin:role:get']);
      Route::put('', 'Role/update')->option(['permission' => 'admin:role:edit', 'logType' => '5']);
      Route::post('', 'Role/add')->option(['permission' => 'admin:role:add', 'logType' => '5']);
      Route::delete(':ids', 'Role/del')->pattern(['ids' => '\d+(,\d+)*'])->option(['permission' => 'admin:role:del', 'logType' => '5']);
   });

   Route::group('sysUser', function () {
      Route::post('list', 'UserAdmin/list')->option(['permission' => 'admin:user:list']);
      Route::post('', 'UserAdmin/add')->option(['permission' => 'admin:user:add', 'logType' => '4']);
      Route::put('', 'UserAdmin/update')->option(['permission' => 'admin:user:edit', 'logType' => '4']);
      Route::get(':id', 'UserAdmin/get')->option(['permission' => 'admin:user:get']);
      Route::delete(':ids', 'UserAdmin/del')->pattern(['ids' => '\d+(,\d+)*'])->option(['permission' => 'admin:user:del', 'logType' => '4']);
   });
   Route::group('upload', function () {
      Route::post('file', 'upload/UploadFile');
      Route::post('editor', 'upload/uploadEditorPhoto');
   });

   Route::group('operate', function () {
      Route::post('list', 'Operate/list')->option(['permission' => 'admin:log:list']);
   });
   Route::group('visitlog', function () {
      Route::post('list', 'Weblog/list')->option(['permission' => 'admin:visitLog:list']);
   });

   Route::group('tool', function () {
      Route::post('list', 'Tool/list')->option(['permission' => 'admin:toolkit:list']);
      Route::get(':id', 'Tool/get')->option(['permission' => 'admin:toolkit:get']);
      Route::put('', 'Tool/update')->option(['permission' => 'admin:toolkit:edit', 'logType' => '7']);
      Route::post('', 'Tool/add')->option(['permission' => 'admin:toolkit:add', 'logType' => '7']);
      Route::delete(':ids', 'Tool/del')->pattern(['ids' => '\d+(,\d+)*'])->option(['permission' => 'admin:toolkit:del', 'logType' => '7']);
   });
   Route::group('label', function () {
      Route::post('list', 'Toollabel/list')->option(['permission' => 'admin:tlabel:list']);
      Route::get(':id', 'Toollabel/get')->option(['permission' => 'admin:tlabel:get']);
      Route::put('', 'Toollabel/update')->option(['permission' => 'admin:tlabel:edit', 'logType' => '6']);
      Route::post('', 'Toollabel/add')->option(['permission' => 'admin:tlabel:add', 'logType' => '6']);
      Route::delete(':ids', 'Toollabel/del')->pattern(['ids' => '\d+(,\d+)*'])->option(['permission' => 'admin:tlabel:del', 'logType' => '6']);
   });
   Route::group('note', function () {
      Route::post('list', 'Note/list')->option(['permission' => 'admin:note:list']);
      Route::get(':id', 'Note/get')->option(['permission' => 'admin:note:get']);
      Route::put('', 'Note/update')->option(['permission' => 'admin:note:edit', 'logType' => '8']);
      Route::post('', 'Note/add')->option(['permission' => 'admin:note:add', 'logType' => '8']);
      Route::delete(':ids', 'Note/del')->pattern(['ids' => '\d+(,\d+)*'])->option(['permission' => 'admin:note:del', 'logType' => '8']);
   });
})->middleware(CheckUser::class)->middleware(CheckPermi::class)->middleware(PrintLog::class);